<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Git | 耶比大熊</title><meta name="author" content="耶比大熊,2324308799@qq.com"><meta name="copyright" content="耶比大熊"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="Git① Git概念Git 是一个分布式版本控制工具，通常用来对软件开发过程中的源代码文件进行管理。通过Git 仓库来存储和管理这些文件，Git 仓库分为两种：①本地仓库：开发人员自己电脑上的 Git 仓库；②远程仓库：远程服务器上的 Git 仓库 ​	commit：提交,将本地文件和版本信息保存到本地仓库 ​	push：推送,将本地仓库文件和版本信息上传到远程仓库 ​	pull：拉取,将远程仓">
<meta property="og:type" content="article">
<meta property="og:title" content="Git">
<meta property="og:url" content="https://cxzde.cn/2024/04/02/note-git/index.html">
<meta property="og:site_name" content="耶比大熊">
<meta property="og:description" content="Git① Git概念Git 是一个分布式版本控制工具，通常用来对软件开发过程中的源代码文件进行管理。通过Git 仓库来存储和管理这些文件，Git 仓库分为两种：①本地仓库：开发人员自己电脑上的 Git 仓库；②远程仓库：远程服务器上的 Git 仓库 ​	commit：提交,将本地文件和版本信息保存到本地仓库 ​	push：推送,将本地仓库文件和版本信息上传到远程仓库 ​	pull：拉取,将远程仓">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://tuchuang.voooe.cn/images/2024/04/07/background4.jpg">
<meta property="article:published_time" content="2024-04-02T09:00:00.000Z">
<meta property="article:modified_time" content="2024-04-02T09:00:00.000Z">
<meta property="article:author" content="耶比大熊">
<meta property="article:tag" content="blog">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://tuchuang.voooe.cn/images/2024/04/07/background4.jpg"><link rel="shortcut icon" href="/favicon.ico"><link rel="canonical" href="https://cxzde.cn/2024/04/02/note-git/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css?v=4.14.0-b1"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar@0.1.16/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.35/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>(()=>{
      const saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
      
      window.btf = {
        saveToLocal: saveToLocal,
        getScript: (url, attr = {}) => new Promise((resolve, reject) => {
          const script = document.createElement('script')
          script.src = url
          script.async = true
          script.onerror = reject
          script.onload = script.onreadystatechange = function() {
            const loadState = this.readyState
            if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
            script.onload = script.onreadystatechange = null
            resolve()
          }

          Object.keys(attr).forEach(key => {
            script.setAttribute(key, attr[key])
          })

          document.head.appendChild(script)
        }),

        getCSS: (url, id = false) => new Promise((resolve, reject) => {
          const link = document.createElement('link')
          link.rel = 'stylesheet'
          link.href = url
          if (id) link.id = id
          link.onerror = reject
          link.onload = link.onreadystatechange = function() {
            const loadState = this.readyState
            if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
            link.onload = link.onreadystatechange = null
            resolve()
          }
          document.head.appendChild(link)
        }),

        addGlobalFn: (key, fn, name = false, parent = window) => {
          const pjaxEnable = false
          if (!pjaxEnable && key.startsWith('pjax')) return

          const globalFn = parent.globalFn || {}
          const keyObj = globalFn[key] || {}
    
          if (name && keyObj[name]) return
    
          name = name || Object.keys(keyObj).length
          keyObj[name] = fn
          globalFn[key] = keyObj
          parent.globalFn = globalFn
        }
      }
    
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode
      
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })()</script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: {"limitDay":365,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":230},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体中文","cht_to_chs":"你已切换为简体中文","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"top-right"},
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid@4.11.1/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: false,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Git',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-04-02 17:00:00'
}</script><link rel="stylesheet" href="/css/mouse.css"><link rel="stylesheet" href="/css/iconfont/iconfont.css"><meta name="generator" content="Hexo 7.1.1"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    btf.addGlobalFn('pjaxSend', () => { preloader.initLoading() }, 'preloader_init')
    btf.addGlobalFn('pjaxComplete', () => { preloader.endLoading() }, 'preloader_end')
  }
})()</script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">10</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="耶比大熊"><span class="site-name">耶比大熊</span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">Git</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-04-02T09:00:00.000Z" title="发表于 2024-04-02 17:00:00">2024-04-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-02T09:00:00.000Z" title="更新于 2024-04-02 17:00:00">2024-04-02</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>10分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Git"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><article class="post-content" id="article-container"><hr>
<h2 id="Git"><a href="#Git" class="headerlink" title="Git"></a>Git</h2><h3 id="①-Git概念"><a href="#①-Git概念" class="headerlink" title="① Git概念"></a>① Git概念</h3><p>Git 是一个分布式版本控制工具，通常用来对软件开发过程中的源代码文件进行管理。通过Git 仓库来存储和管理这些文件，Git 仓库分为两种：①<strong>本地仓库</strong>：开发人员自己电脑上的 Git 仓库；②<strong>远程仓库</strong>：远程服务器上的 Git 仓库</p>
<p>​	<strong>commit</strong>：提交,将本地文件和版本信息保存到本地仓库</p>
<p>​	<strong>push</strong>：推送,将本地仓库文件和版本信息上传到远程仓库</p>
<p>​	<strong>pull</strong>：拉取,将远程仓库文件和版本信息下载到本地仓库</p>
<img src= "" data-lazy-src="https://cdn.jsdelivr.net/gh/cxz206015/For-PicGo@main/img/1.png" style="zoom:70%;" />

<h3 id="②-工作区、暂存区、版本库"><a href="#②-工作区、暂存区、版本库" class="headerlink" title="② 工作区、暂存区、版本库"></a>② 工作区、暂存区、版本库</h3><p>​	<strong>版本库</strong>：前面看到的.git隐藏文件夹就是版本库，版本库中存储了很多配置信息、日志信息和文件版本信息等</p>
<p>​	<strong>工作区</strong>：包含.git文件夹的目录就是工作区，也称为工作目录，主要用于存放开发的代码</p>
<p>​	<strong>暂存区</strong>：.git文件夹中有很多文件，其中有一个index文件就是暂存区，也可以叫做stage。暂存区是一个临时保存修改文件的地方</p>
<img src= "" data-lazy-src="https://cdn.jsdelivr.net/gh/cxz206015/For-PicGo@main/img/2.jpg" style="zoom:100%;" />

<h3 id="③-git工作区文件状态"><a href="#③-git工作区文件状态" class="headerlink" title="③ git工作区文件状态"></a>③ git工作区文件状态</h3><p>Git工作区中的文件存在两种状态：<code>untracked </code> 未跟踪（未被纳入版本控制）和 <code>tracked</code> 已跟踪（被纳入版本控制）</p>
<table>
<thead>
<tr>
<th align="center">Unmodified</th>
<th align="center">未修改状态</th>
<th align="center">颜色</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Modified</td>
<td align="center">已修改状态</td>
<td align="center">红色</td>
</tr>
<tr>
<td align="center">staged</td>
<td align="center">已暂存状态</td>
<td align="center">绿色</td>
</tr>
</tbody></table>
<hr>
<h2 id="常用指令"><a href="#常用指令" class="headerlink" title="常用指令"></a>常用指令</h2><h3 id="Git全局设置"><a href="#Git全局设置" class="headerlink" title="Git全局设置"></a>Git全局设置</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#设置用户信息</span></span><br><span class="line">git config --global user.name <span class="string">&quot;cxz206015&quot;</span></span><br><span class="line">git config --global user.email <span class="string">&quot;206015cxz@gmail.com&quot;</span></span><br><span class="line"><span class="comment">#查看配置信息</span></span><br><span class="line">git config --list</span><br></pre></td></tr></table></figure>

<h3 id="获取Git仓库"><a href="#获取Git仓库" class="headerlink" title="获取Git仓库"></a>获取Git仓库</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1.在本地初始化一个Git仓库：</span></span><br><span class="line">git init</span><br><span class="line"><span class="comment">#2.从远程仓库克隆（常用）:  </span></span><br><span class="line">git <span class="built_in">clone</span> &lt; url &gt;</span><br></pre></td></tr></table></figure>

<h3 id="本地仓库操作"><a href="#本地仓库操作" class="headerlink" title="本地仓库操作"></a>本地仓库操作</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#本地仓库常用命令如下:</span></span><br><span class="line">git status			 				<span class="comment">#查看文件状态</span></span><br><span class="line">git add	&lt;file&gt;						<span class="comment">#将文件的修改加入暂存区</span></span><br><span class="line">git add .                       	<span class="comment">#将所有文件添加到暂存区</span></span><br><span class="line">git reset &lt;file&gt;					<span class="comment">#将暂存区的文件取消暂存暂存或者切换到指定版本</span></span><br><span class="line">git reset --hard &lt;file&gt;	</span><br><span class="line">git commit			 				<span class="comment">#将暂存区的文件修改提交到版本库</span></span><br><span class="line">git commit -a			 			<span class="comment">#提交到本地库等待push</span></span><br><span class="line">git commit -m <span class="string">&quot;message&quot;</span> &lt;file&gt;		<span class="comment">#提交指定文件</span></span><br><span class="line">git <span class="built_in">log</span>				 				<span class="comment">#查看日志</span></span><br></pre></td></tr></table></figure>

<h3 id="远程仓库操作"><a href="#远程仓库操作" class="headerlink" title="远程仓库操作"></a>远程仓库操作</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">git remote							<span class="comment">#查看远程仓库</span></span><br><span class="line">git remote -v						<span class="comment">#查看版本</span></span><br><span class="line">git remote add &lt;shortname&gt; &lt;url&gt;	<span class="comment">#添加远程仓库(关联) shortname:简称</span></span><br><span class="line">git pull &lt;remote-name&gt; &lt;branch&gt;		<span class="comment">#从远程仓库拉取(下载) remote-name:origin 远程仓库名 branch:分支名称 master</span></span><br><span class="line">git push orign master				<span class="comment">#推送到远程仓库(上传) origin master</span></span><br><span class="line">  	--allow-unrelated-histories 	<span class="comment">#合并git init的本地仓库和远程仓库报错，在push后面添加</span></span><br></pre></td></tr></table></figure>

<h3 id="分支操作"><a href="#分支操作" class="headerlink" title="分支操作"></a>分支操作</h3><p>分支是动态的，通过<strong>git init</strong> 命令创建本地仓库时会默认创建一个 <strong>master</strong> 分支</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">git branch							<span class="comment">#查看分支(列出所有本地分支)</span></span><br><span class="line">git branch -r						<span class="comment">#列出所有远程分支</span></span><br><span class="line">git branch -a						<span class="comment">#列出所有本地和远程分支</span></span><br><span class="line">git branch &lt;name&gt;					<span class="comment">#创建分支</span></span><br><span class="line">git checkout &lt;name&gt;					<span class="comment">#切换分支</span></span><br><span class="line">git merge &lt;name&gt;					<span class="comment">#合并分支 编辑窗口按&quot;i&quot;可以添加&quot;message&quot;，ESC退出，再输入&quot;:wq&quot;保存退出</span></span><br><span class="line"><span class="comment">#合并相同文件会发生冲突:先解决冲突，git add结束合并分支，再git commit -m &quot;message&quot; &lt;file&gt;提交，若出现&quot;cannot do a 	#partial commit during a merge&quot;，则在其后面加上&quot;-i&quot;，然后git push origin master推送到远程仓库实现合并</span></span><br></pre></td></tr></table></figure>

<h3 id="标签操作"><a href="#标签操作" class="headerlink" title="标签操作"></a>标签操作</h3><p>标签是静态的</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git tag								<span class="comment">#列出已有的标签</span></span><br><span class="line">git tag &lt;name&gt;						<span class="comment">#创建标签</span></span><br><span class="line">git checkout -b &lt;branch&gt; &lt;name&gt;		<span class="comment">#检出标签 branch:分支名 name:标签名</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 开始：检查git配置 (可不做)</span></span><br><span class="line">git config --list											<span class="comment"># 查看配置信息</span></span><br><span class="line">git config --global core.editor vim                     	<span class="comment"># 设置默认编辑器为vim（git默认用nano）</span></span><br><span class="line">git config core.ignorecase <span class="literal">false</span>                        	<span class="comment"># 设置大小写敏感</span></span><br><span class="line">git config --global user.name <span class="string">&quot;YOUR NAME&quot;</span>  					<span class="comment"># 设置用户名</span></span><br><span class="line">git config --global user.email <span class="string">&quot;YOUR EMAIL ADDRESS&quot;</span>			<span class="comment"># 设置邮箱</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第一步：初始化一个仓库</span></span><br><span class="line">git init						  							<span class="comment"># 初始化本地版本库</span></span><br><span class="line">git <span class="built_in">clone</span> &lt;url&gt;				 								<span class="comment"># 克隆远程版本库</span></span><br><span class="line">git remote add origin git@github.com:用户名/仓库名.git	 	<span class="comment"># 配置远程git版本库</span></span><br><span class="line">git pull origin master                                      <span class="comment"># 下载代码及快速合并 </span></span><br><span class="line">git fetch origin                                            <span class="comment"># 从远程库获取代码</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第二步：查看状态 (可不做)</span></span><br><span class="line">git status                     		<span class="comment"># 查看git当前状态</span></span><br><span class="line">git <span class="built_in">log</span>                             <span class="comment"># 查看提交历史</span></span><br><span class="line">git diff                        	<span class="comment"># 查看变更内容</span></span><br><span class="line">git branch                          <span class="comment"># 显示所有分支</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第三步：修改文件 (可不做)</span></span><br><span class="line">git <span class="built_in">mv</span> &lt;old&gt; &lt;new&gt;              	<span class="comment"># 文件改名</span></span><br><span class="line">git <span class="built_in">rm</span> &lt;file&gt;                   	<span class="comment"># 删除文件</span></span><br><span class="line">git <span class="built_in">rm</span> --cached &lt;file&gt;          	<span class="comment"># 停止跟踪文件但不删除</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第四步：切换提交分支 (可不做)</span></span><br><span class="line">git branch							<span class="comment">#查看分支 (列出所有本地分支)</span></span><br><span class="line">git branch -r						<span class="comment">#列出所有远程分支</span></span><br><span class="line">git branch -a						<span class="comment">#列出所有本地和远程分支</span></span><br><span class="line">git branch &lt;name&gt;					<span class="comment">#创建分支</span></span><br><span class="line">git checkout &lt;name&gt;					<span class="comment">#切换分支</span></span><br><span class="line">git merge &lt;name&gt;					<span class="comment">#合并分支 编辑窗口按&quot;i&quot;可以添加&quot;message&quot;，ESC退出，再输入&quot;:wq&quot;保存退出</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第五步：保存和提交</span></span><br><span class="line">git add .                       	<span class="comment"># 跟踪所有改动过的文件</span></span><br><span class="line">git add &lt;file&gt;                  	<span class="comment"># 跟踪指定的文件</span></span><br><span class="line"></span><br><span class="line">git checkout master                 <span class="comment"># 切换到master分支</span></span><br><span class="line">git switch dev						<span class="comment"># 切换到dev分支</span></span><br><span class="line">git checkout -b dev                 <span class="comment"># 创建并切换到dev分支</span></span><br><span class="line"></span><br><span class="line">git commit			 				<span class="comment"># 将暂存区的文件修改提交到版本库</span></span><br><span class="line">git commit -a			 			<span class="comment"># 提交到本地库等待push</span></span><br><span class="line">git commit -m <span class="string">&quot;first commit&quot;</span>  		<span class="comment"># 提交所有更新过的文件备注为&quot;first commit&quot;</span></span><br><span class="line">git commit -am <span class="string">&quot;first commit&quot;</span>		<span class="comment"># 提交锁头</span></span><br><span class="line">git commit --amend              	<span class="comment"># 修改最后一次提交。即没有增加新的提交记录，相当于将当前的修改追加到上一次的提交中</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第五步：提交到远程仓库</span></span><br><span class="line">git push							<span class="comment"># 提交到远程仓库</span></span><br><span class="line">git push origin master              <span class="comment"># 上传代码及快速合并</span></span><br></pre></td></tr></table></figure>

<img src= "" data-lazy-src="https://cdn.jsdelivr.net/gh/cxz206015/For-PicGo@main/img/3.jpg" style="zoom:67%;" />

<p><strong>全部指令</strong></p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br></pre></td><td class="code"><pre><span class="line">git init                                                  <span class="comment"># 初始化本地git仓库（创建新仓库）</span></span><br><span class="line">git config --global user.name <span class="string">&quot;xxx&quot;</span>                       <span class="comment"># 配置用户名</span></span><br><span class="line">git config --global user.email <span class="string">&quot;xxx@xxx.com&quot;</span>              <span class="comment"># 配置邮件</span></span><br><span class="line">git config --global color.ui <span class="literal">true</span>                         <span class="comment"># git status等命令自动着色</span></span><br><span class="line">git config --global color.status auto</span><br><span class="line">git config --global color.diff auto</span><br><span class="line">git config --global color.branch auto</span><br><span class="line">git config --global color.interactive auto</span><br><span class="line">git config --global --<span class="built_in">unset</span> http.proxy                    <span class="comment"># remove  proxy configuration on git</span></span><br><span class="line">git <span class="built_in">clone</span> git+ssh://git@192.168.53.168/VT.git             <span class="comment"># clone远程仓库</span></span><br><span class="line">git status                                                <span class="comment"># 查看当前版本状态（是否修改）</span></span><br><span class="line">git add xyz                                               <span class="comment"># 添加xyz文件至index</span></span><br><span class="line">git add .                                                 <span class="comment"># 增加当前子目录下所有更改过的文件至index</span></span><br><span class="line">git commit -m <span class="string">&#x27;xxx&#x27;</span>                                       <span class="comment"># 提交</span></span><br><span class="line">git commit --amend -m <span class="string">&#x27;xxx&#x27;</span>                               <span class="comment"># 合并上一次提交（用于反复修改）</span></span><br><span class="line">git commit -am <span class="string">&#x27;xxx&#x27;</span>                                      <span class="comment"># 将add和commit合为一步</span></span><br><span class="line">git <span class="built_in">rm</span> xxx                                                <span class="comment"># 删除index中的文件</span></span><br><span class="line">git <span class="built_in">rm</span> -r *                                               <span class="comment"># 递归删除</span></span><br><span class="line">git <span class="built_in">log</span>                                                   <span class="comment"># 显示提交日志</span></span><br><span class="line">git <span class="built_in">log</span> -1                                                <span class="comment"># 显示1行日志 -n为n行</span></span><br><span class="line">git <span class="built_in">log</span> -5</span><br><span class="line">git <span class="built_in">log</span> --<span class="built_in">stat</span>                                            <span class="comment"># 显示提交日志及相关变动文件</span></span><br><span class="line">git <span class="built_in">log</span> -p -m</span><br><span class="line">git show dfb02e6e4f2f7b573337763e5c0013802e392818         <span class="comment"># 显示某个提交的详细内容</span></span><br><span class="line">git show dfb02                                            <span class="comment"># 可只用commitid的前几位</span></span><br><span class="line">git show HEAD                                             <span class="comment"># 显示HEAD提交日志</span></span><br><span class="line">git show HEAD^                                            <span class="comment"># 显示HEAD的父（上一个版本）的提交日志 ^^为上两个版本 																							  ^5为上5个版本</span></span><br><span class="line">git tag                                                   <span class="comment"># 显示已存在的tag</span></span><br><span class="line">git tag -a v2.0 -m <span class="string">&#x27;xxx&#x27;</span>                                  <span class="comment"># 增加v2.0的tag</span></span><br><span class="line">git show v2.0                                             <span class="comment"># 显示v2.0的日志及详细内容</span></span><br><span class="line">git <span class="built_in">log</span> v2.0                                              <span class="comment"># 显示v2.0的日志</span></span><br><span class="line">git diff                                                  <span class="comment"># 显示所有未添加至index的变更</span></span><br><span class="line">git diff --cached                                         <span class="comment"># 显示所有已添加index但还未commit的变更</span></span><br><span class="line">git diff HEAD^                                            <span class="comment"># 比较与上一个版本的差异</span></span><br><span class="line">git diff HEAD -- ./lib                                    <span class="comment"># 比较与HEAD版本lib目录的差异</span></span><br><span class="line">git diff origin/master..master                            <span class="comment"># 比较远程分支master上有本地分支master上没有的</span></span><br><span class="line">git diff origin/master..master --<span class="built_in">stat</span>                     <span class="comment"># 只显示差异的文件，不显示具体内容</span></span><br><span class="line">git remote add origin git+ssh://git@192.168.53.168/VT.git <span class="comment"># 增加远程定义（用于push/pull/fetch）</span></span><br><span class="line">git branch                                                <span class="comment"># 显示本地分支</span></span><br><span class="line">git branch --contains 50089                               <span class="comment"># 显示包含提交50089的分支</span></span><br><span class="line">git branch -a                                             <span class="comment"># 显示所有分支</span></span><br><span class="line">git branch -r                                             <span class="comment"># 显示所有原创分支</span></span><br><span class="line">git branch --merged                                       <span class="comment"># 显示所有已合并到当前分支的分支</span></span><br><span class="line">git branch --no-merged                                    <span class="comment"># 显示所有未合并到当前分支的分支</span></span><br><span class="line">git branch -m master master_copy                          <span class="comment"># 本地分支改名</span></span><br><span class="line">git checkout -b master_copy                               <span class="comment"># 从当前分支创建新分支master_copy并检出</span></span><br><span class="line">git checkout -b master master_copy                        <span class="comment"># 上面的完整版</span></span><br><span class="line">git checkout features/performance                         <span class="comment"># 检出已存在的features/performance分支</span></span><br><span class="line">git checkout --track hotfixes/BJVEP933                    <span class="comment"># 检出远程分支hotfixes/BJVEP933并创建本地跟踪分支</span></span><br><span class="line">git checkout v2.0                                         <span class="comment"># 检出版本v2.0</span></span><br><span class="line">git checkout -b devel origin/develop                      <span class="comment"># 从远程分支develop创建新本地分支devel并检出</span></span><br><span class="line">git checkout -- README                                    <span class="comment"># 检出head版本的README文件（可用于修改错误回退）</span></span><br><span class="line">git merge origin/master                                   <span class="comment"># 合并远程master分支至当前分支</span></span><br><span class="line">git cherry-pick ff44785404a8e                             <span class="comment"># 合并提交ff44785404a8e的修改</span></span><br><span class="line">git push origin master                                    <span class="comment"># 将当前分支push到远程master分支</span></span><br><span class="line">git push origin :hotfixes/BJVEP933                        <span class="comment"># 删除远程仓库的hotfixes/BJVEP933分支</span></span><br><span class="line">git push --tags                                           <span class="comment"># 把所有tag推送到远程仓库</span></span><br><span class="line">git fetch                                                 <span class="comment"># 获取所有远程分支（不更新本地分支，另需merge）</span></span><br><span class="line">git fetch --prune                                         <span class="comment"># 获取所有原创分支并清除服务器上已删掉的分支</span></span><br><span class="line">git pull origin master                                    <span class="comment"># 获取远程分支master并merge到当前分支</span></span><br><span class="line">git <span class="built_in">mv</span> README README2                                     <span class="comment"># 重命名文件README为README2</span></span><br><span class="line">git reset --hard HEAD                                     <span class="comment"># 将当前版本重置为HEAD（通常用于merge失败回退）</span></span><br><span class="line">git rebase</span><br><span class="line">git branch -d hotfixes/BJVEP933                           <span class="comment"># 删除分支hotfixes/BJVEP933（本分支修改已合并到其他分支）</span></span><br><span class="line">git branch -D hotfixes/BJVEP933                           <span class="comment"># 强制删除分支hotfixes/BJVEP933</span></span><br><span class="line">git ls-files                                              <span class="comment"># 列出git index包含的文件</span></span><br><span class="line">git show-branch                                           <span class="comment"># 图示当前分支历史</span></span><br><span class="line">git show-branch --all                                     <span class="comment"># 图示所有分支历史</span></span><br><span class="line">git whatchanged                                           <span class="comment"># 显示提交历史对应的文件修改</span></span><br><span class="line">git revert dfb02e6e4f2f7b573337763e5c0013802e392818       <span class="comment"># 撤销提交dfb02e6e4f2f7b573337763e5c0013802e392818</span></span><br><span class="line">git ls-tree HEAD                                          <span class="comment"># 内部命令：显示某个git对象</span></span><br><span class="line">git rev-parse v2.0                                        <span class="comment"># 内部命令：显示某个ref对于的SHA1 HASH</span></span><br><span class="line">git reflog                                                <span class="comment"># 显示所有提交，包括孤立节点</span></span><br><span class="line">git show HEAD@&#123;5&#125;</span><br><span class="line">git show master@&#123;yesterday&#125;                               <span class="comment"># 显示master分支昨天的状态</span></span><br><span class="line">git <span class="built_in">log</span> --pretty=format:<span class="string">&#x27;%h %s&#x27;</span> --graph                   <span class="comment"># 图示提交日志</span></span><br><span class="line">git show HEAD~3</span><br><span class="line">git show -s --pretty=raw 2be7fcb476</span><br><span class="line">git stash                                                 <span class="comment"># 暂存当前修改，将所有至为HEAD状态</span></span><br><span class="line">git stash list                                            <span class="comment"># 查看所有暂存</span></span><br><span class="line">git stash show -p stash@&#123;0&#125;                               <span class="comment"># 参考第一次暂存</span></span><br><span class="line">git stash apply stash@&#123;0&#125;                                 <span class="comment"># 应用第一次暂存</span></span><br><span class="line">git grep <span class="string">&quot;delete from&quot;</span>                                    <span class="comment"># 文件中搜索文本“delete from”</span></span><br><span class="line">git grep -e <span class="string">&#x27;#define&#x27;</span> --and -e SORT_DIRENT</span><br><span class="line">git gc</span><br><span class="line">git fsck</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="忽略提交文件-gitignore"><a href="#忽略提交文件-gitignore" class="headerlink" title="忽略提交文件 .gitignore"></a>忽略提交文件 <code>.gitignore</code></h2><figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># .gitignore文件</span></span><br><span class="line"><span class="comment"># maven #</span></span><br><span class="line">target</span><br><span class="line"></span><br><span class="line"><span class="comment"># log #</span></span><br><span class="line">logs</span><br><span class="line"></span><br><span class="line"><span class="comment"># windows #</span></span><br><span class="line">Thumbs.db</span><br><span class="line"></span><br><span class="line"><span class="comment"># Mac #</span></span><br><span class="line">.DS_Store</span><br><span class="line"></span><br><span class="line"><span class="comment"># eclipse #</span></span><br><span class="line">.settings</span><br><span class="line">.project</span><br><span class="line">.classpath</span><br><span class="line">.log</span><br><span class="line">*.class</span><br><span class="line"></span><br><span class="line"><span class="comment"># idea #</span></span><br><span class="line">.idea</span><br><span class="line">*.iml</span><br><span class="line"></span><br><span class="line"><span class="comment"># Package Files #</span></span><br><span class="line">*.jar</span><br><span class="line">*.war</span><br><span class="line">*.ear</span><br><span class="line">/target</span><br></pre></td></tr></table></figure>



</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://cxzde.cn">耶比大熊</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://cxzde.cn/2024/04/02/note-git/">https://cxzde.cn/2024/04/02/note-git/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://cxzde.cn" target="_blank">耶比大熊</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://tuchuang.voooe.cn/images/2024/04/07/background4.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2024/04/03/note-maven/" title="Maven"><img class="cover" src= "" data-lazy-src="https://tuchuang.voooe.cn/images/2024/04/07/background1.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Maven</div></div></a></div><div class="next-post pull-right"><a href="/2024/04/01/note-java/" title="Java"><img class="cover" src= "" data-lazy-src="https://tuchuang.voooe.cn/images/2024/04/07/background2.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Java</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/img/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">耶比大熊</div><div class="author-info__description">隐约雷鸣 阴霾天空 但盼风雨来 能留你在此</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">10</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" href="https://cxzde.cn"><i></i><span>🚀异次元之旅🚀</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/cxz206015" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:2324308799@qq.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a><a class="social-icon" href="https://www.zhihu.com/people/ashbell" target="_blank" title="知乎"><i class="iconfont icon-zhihu-circle-fill"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content"><div style="text-align:center;"><a target="_blank" rel="noopener" href="https://www.bilibili.com/bangumi/play/ep785525/?share_source=copy_web">节选自——《凡人修仙传》86集 文戏<br></a></span>吾幼时好棋 <br>名镇乡野 <br>人皆谓神童 <br>年岁稍长 遇一山野老道 <br>三天对弈 终得一胜 <br>老道愿赌服输 施展法术 <br>通天遁地 <br>吾顿生神往 <br>遂弃棋修道 <br>可惜吾天赋一般 <br>只求矜矜业业 苦心钻研 <br>不惜远家人 抛爱侣 <br>弃友人 漂泊四海 无所依绊 <br>几经险境 <br>半生贫苦 <br>老来方有定所 <br>可惜 时日无多 <br>近来常思 <br>人生百年 蜉蝣一日 <br>长生于我何有哉 <br>不过又入樊笼尔 <br>不若二三好友 <br>弈棋饮酒 <br>良缘佳侣 人间携手 <br>风光百年 同归尘土 <br>但 <br>问道之心 <br>终归难改 <br>纵使蹉跎一生 <br>也要争那 一线天机 <br>只因幼时便知 <br>人生如棋 <br>落子 <br>无悔 <br></div></div><button></button></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Git"><span class="toc-number">1.</span> <span class="toc-text">Git</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A0-Git%E6%A6%82%E5%BF%B5"><span class="toc-number">1.1.</span> <span class="toc-text">① Git概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A1-%E5%B7%A5%E4%BD%9C%E5%8C%BA%E3%80%81%E6%9A%82%E5%AD%98%E5%8C%BA%E3%80%81%E7%89%88%E6%9C%AC%E5%BA%93"><span class="toc-number">1.2.</span> <span class="toc-text">② 工作区、暂存区、版本库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E2%91%A2-git%E5%B7%A5%E4%BD%9C%E5%8C%BA%E6%96%87%E4%BB%B6%E7%8A%B6%E6%80%81"><span class="toc-number">1.3.</span> <span class="toc-text">③ git工作区文件状态</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E6%8C%87%E4%BB%A4"><span class="toc-number">2.</span> <span class="toc-text">常用指令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Git%E5%85%A8%E5%B1%80%E8%AE%BE%E7%BD%AE"><span class="toc-number">2.1.</span> <span class="toc-text">Git全局设置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8E%B7%E5%8F%96Git%E4%BB%93%E5%BA%93"><span class="toc-number">2.2.</span> <span class="toc-text">获取Git仓库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93%E6%93%8D%E4%BD%9C"><span class="toc-number">2.3.</span> <span class="toc-text">本地仓库操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E6%93%8D%E4%BD%9C"><span class="toc-number">2.4.</span> <span class="toc-text">远程仓库操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%86%E6%94%AF%E6%93%8D%E4%BD%9C"><span class="toc-number">2.5.</span> <span class="toc-text">分支操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A0%87%E7%AD%BE%E6%93%8D%E4%BD%9C"><span class="toc-number">2.6.</span> <span class="toc-text">标签操作</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%80%BB%E7%BB%93"><span class="toc-number">3.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BF%BD%E7%95%A5%E6%8F%90%E4%BA%A4%E6%96%87%E4%BB%B6-gitignore"><span class="toc-number">4.</span> <span class="toc-text">忽略提交文件 .gitignore</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2024 By 耶比大熊</div><div class="footer_custom_text">隐约雷鸣 阴霾天空 即使天无雨 我亦留此地<p><a target="_blank" href="https://hexo.io/" style="margin-inline:5px" title="博客框架为Hexo"><img src= "" data-lazy-src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&amp;logo=hexo" alt="博客框架为Hexo" ></a><a target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" title="博客主题为Butterfly"><img src= "" data-lazy-src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&amp;logo=bitdefender" alt="博客主题为Butterfly" ></a><a target="_blank" href="https://vercel.com/" style="margin-inline:5px" title="本站采用多线部署，主线路托管于Vercel"><img src= "" data-lazy-src="https://img.shields.io/badge/Hosted-Vercel-brightgreen?style=flat&amp;logo=Vercel" alt="本站采用多线部署，主线路托管于Vercel" ></a><a target="_blank" href="https://icp.gov.moe/?keyword=20245209" style="margin-inline:5px" title="本站已加入萌ICP豪华套餐，萌ICP备20245209号"><img src= "" data-lazy-src="https://img.shields.io/badge/%E8%90%8CICP%E5%A4%87-20245209-ff1485?style=flat&amp;logo=Bitwarden" alt="本站已加入萌ICP豪华套餐，萌ICP备20245209号" ></a><a target="_blank" href="https://github.com/" style="margin-inline:5px" title="本网站源码由Github提供存储仓库托管"><img src= "" data-lazy-src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&amp;logo=GitHub" alt="本网站源码由Github提供存储仓库托管" ></a><a target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" style="margin-inline:5px" title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可"><img src= "" data-lazy-src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&amp;logo=Claris" alt="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可" ></a></p></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js?v=4.14.0-b1"></script><script src="/js/main.js?v=4.14.0-b1"></script><script src="/js/tw_cn.js?v=4.14.0-b1"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.35/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page@5.2.0/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@19.0.5/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar@0.1.16/dist/snackbar.min.js"></script><script>(() => {
  const panguFn = () => {
    if (typeof pangu === 'object') pangu.autoSpacingPage()
    else {
      btf.getScript('https://cdn.jsdelivr.net/npm/pangu@4.0.7/dist/browser/pangu.min.js')
        .then(() => {
          pangu.autoSpacingPage()
        })
    }
  }

  const panguInit = () => {
    if (false){
      GLOBAL_CONFIG_SITE.isPost && panguFn()
    } else {
      panguFn()
    }
  }

  btf.addGlobalFn('pjaxComplete', panguInit, 'pangu')
  document.addEventListener('DOMContentLoaded', panguInit)
})()</script><div class="js-pjax"></div><script defer src="https://cdn.jsdelivr.net/gh/cxz206015/live2d-widget/autoload.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="30" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1.1.3/dist/canvas-nest.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js?v=4.14.0-b1"></script></div></div></body></html>